﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TreaShares.Backoffice.Controlers;

namespace TreaShares.Backoffice.User
{
    public partial class Stocks : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ObjectDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {
            //var ddlStockTypes = this.DetailsView1.FindControl("ddlStockTypes") as DropDownList;
            //e.InputParameters["stockCode"] = int.Parse(ddlStockTypes.SelectedValue);

            //var ddlCurrency = this.DetailsView1.FindControl("ddlCurrency") as DropDownList;
            //e.InputParameters["currency"] = ddlCurrency.SelectedValue;

        }


        protected void btnStockInsert_Click(object sender, EventArgs e)
        {
            string stockName = Request.Form["txtStockName"];
            int stockCode = int.Parse(this.ddlStockTypes.SelectedValue);
            string currency = this.ddlCurrency.SelectedValue;
            string txtIssFVMultiplier = Request.Form["txtIssFVMultiplier"];
            double? issFVMultiplier = null;
            if (!string.IsNullOrEmpty(txtIssFVMultiplier))
                issFVMultiplier = double.Parse(txtIssFVMultiplier);

            string txtIndustryBurnRate = Request.Form["txtIndustryBurnRate"];
            double? industryBurnRate = null;
            if (!string.IsNullOrEmpty(txtIndustryBurnRate))
                industryBurnRate = double.Parse(txtIndustryBurnRate);
            float parValue = float.Parse(Request.Form["txtParValue"]);
            StocksManager stocksManager = new StocksManager();
            stocksManager.Insert(stockName, stockCode, this.Master.OrgBasicInfo.Id, currency, issFVMultiplier, industryBurnRate, parValue);
            this.GridView1.DataBind();
        }
    }
}